package com.kyh.controller.api.sys;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kyh.service.sys.RoleButtonService;
import com.kyh.util.CheckUtil;
import com.kyh.vo.R;

@Controller
@RequestMapping("/api/inter/roleButton")
public class ApiInterRoleButtonController {

	@Autowired
	private RoleButtonService roleButtonService;
	
	@PostMapping("/deleteTrueByUk")
    @ResponseBody
	public R deleteTrueByUk(Model model, HttpServletRequest request, HttpServletResponse response,
			Long roleId,
			Long buttonId
			){
		
		R retMsg;
		if (!CheckUtil.notNull(roleId)) {
			retMsg = R.error("角色ID不能为空");
		}
		
		if (!CheckUtil.notNull(buttonId)) {
			retMsg = R.error("按钮ID不能为空");
		}
		try {
			retMsg = roleButtonService.deleteTrueByUk(
					roleId,
					buttonId
					);
		} catch (Exception e) {
			retMsg = R.error("服务器正在开小差，请联系客服");
		}
		
		return retMsg;
	}
}